package shared.io.game;

import java.awt.Point;
import java.io.Serializable;
import java.util.Date;
import java.util.Random;

import shared.PlayerColours;
/**
 * Player
 */
public class Player extends Lightable implements Serializable {

   private static final long serialVersionUID = -2759671233357337507L;
   private int playerColor;
   /**
    * Player name
    */
   private String name;
   /**
    * Unique player ID
    */
   private int id;
   
   /**
    * @param name    player name
    */
   public Player(String name, int playerColor) {
      this.playerColor = playerColor;
      Date date = new Date();
      this.name = name;
      Random random = new Random();
      id = Integer.valueOf(
            Long.toString(date.getTime()).substring(6) +
            Long.toString(random.nextInt(100)));
   }

   public String getName() {
      return name;
   }

   public int getId() {
      return id;
   }

   @Override
   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      Player other = (Player) obj;
      if (id != other.id)
         return false;
      return true;
   }

   public int getPlayerColor() {
      return playerColor;
   }
   
   public void moveUp() {
      y--;
   }
   
   public void moveRight() {
      x++;
   }
   
   public void moveDown() {
      y++;
   }
   
   public void moveLeft() {
      x--;
   }
}
